/*
 * @author: sanbao
 * @Date: 2022-08-06 12:27:52
 */
import router from "./router";
import { getToken } from './utils/auth'
import { ElNotification } from "element-plus";
// 全局前置守卫
router.beforeEach((to, from, next) => {
    const token = getToken()
    if (token) {
        if (to.path != '/login') {
            next()
        } else {
            next({
                path: from.path ? from.path : '/'
            })
            ElNotification.error('已经登陆过了不能重复登陆哦😘😘')
        }
    } else {
        if (to.path != '/login') {
            next('/login')
        } else {
            next()
        }
    }
})